import 'package:flutter_reactive_value/flutter_reactive_value.dart';
import 'weather_entity.dart';

/// 天气控制器
class WeatherController {
  static final WeatherController _instance = WeatherController._();
  static WeatherController get globalInstance => _instance;
  
  WeatherController._();

  /// 当前天气数据
  final ReactiveValueNotifier<WeatherEntity?> _currentWeather =
      ReactiveValueNotifier<WeatherEntity?>(null);

  ReactiveValueNotifier<WeatherEntity?> get currentWeatherState => _currentWeather;

  /// 随机获取一种天气数据
  void getRandomWeather() {
    final weather = WeatherEntity.getRandomWeather();
    _currentWeather.value = weather;
  }

  /// 根据ID选择天气数据
  void selectWeatherById(String id) {
    final weather = WeatherEntity.findWeatherByIdentifier(id);
    _currentWeather.value = weather;
  }
}
